package com.splic.product.service.impl;

import cn.hutool.core.date.DateUtil;
import com.splic.common.utils.DateUtils;
import com.splic.product.dto.DeviceStatisDto;
import com.splic.product.mapper.DeviceMapper;
import com.splic.product.mapper.ProductMapper;
import com.splic.product.mapper.UserActiveMapper;
import com.splic.product.service.DeviceStatisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 用户设备Service业务层处理
 * 
 * @author singe
 * @date 2022-01-04
 */
@Service
public class DeviceStatisServiceImpl implements DeviceStatisService
{
    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private UserActiveMapper userActiveMapper;
    @Autowired
    private ProductMapper productMapper;

    /**
     * 查询用户设备列表
     * 
     * @param device 用户设备
     * @return 用户设备
     */
    @Override
    public List<DeviceStatisDto> selectAddStatisPageList(DeviceStatisDto deviceStatisDto)
    {
        Date date = DateUtils.addDays(DateUtils.parseDate(deviceStatisDto.getEndCreateTime()), 1);
        deviceStatisDto.setEndCreateTime(DateUtil.formatDate(date));
        return deviceMapper.selectAddStatisPageList(deviceStatisDto);
    }


    @Override
    public List<String> selectAddPhoneBrandList() {
        return deviceMapper.selectAddPhoneBrandList();
    }

    @Override
    public List<String> selectAddAndroidVersionList() {
        return deviceMapper.selectAddAndroidVersionList();
    }


    @Override
    public List<DeviceStatisDto> selectActiveStatisPageList(DeviceStatisDto deviceStatisDto) {
        Date date = DateUtils.addDays(DateUtils.parseDate(deviceStatisDto.getEndCreateTime()), 1);
        deviceStatisDto.setEndCreateTime(DateUtil.formatDate(date));
        return userActiveMapper.selectActiveStatisPageList(deviceStatisDto);
    }

    @Override
    public List<String> selectActivePhoneBrandList() {
        return userActiveMapper.selectActivePhoneBrandList();
    }

    @Override
    public List<String> selectActiveAndroidVersionList(String phoneBrand) {
        return userActiveMapper.selectActiveAndroidVersionList(phoneBrand);
    }

    @Override
    public List<String> selectAddPhoneModelList() {
        return deviceMapper.selectAddPhoneModelList();
    }

    @Override
    public List<String> selectAddProductVersionList(Long productId) {
        return productMapper.selectAddProductVersionList(productId);
    }
}
